<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'PersonalCenter.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css" href="css/address.css">
<link rel="stylesheet" type="text/css" href="css/flower.css">
<link rel="stylesheet" type="text/css" href="css/flowerYang.css">
<link rel="stylesheet" type="text/css" href="css/flowerShen.css">
<link rel="stylesheet" type="text/css" href="css/collect.css">

<style type="text/css">
.add-address:hover {
	color: #fff;
}
.delete-address-icon {
	margin: 36px auto 12px;
	display: block;
}
.delete-address-title {
	text-align: center;
	font-size: 21px;
	color: #232628;
	margin-bottom: 32px;
}
.consigneeModal-btn {
	width: 108px;
	text-align: center;
	height: 36px;
	line-height: 36px;
	color: white;
	font-size: 13px;
	background: #FF734C;
	background: linear-gradient(90deg, #FF734C 0%, #FF3D12 100%);
	border-radius: 20px;
	display: inline-block;
	cursor: pointer;
}
.consigneeModal-btn-grey {
	color: #71797F;
	background: #FFFFFF;
	border: 1px solid #E9ECF0;
}
</style>
</head>
<body class="home">
	<%@ include file="GeTop.jsp"%>
	<!-- 导航 End -->
	<div class="main clearfix">
		<div class="main-container">
			<div class="breadcrumbs">
				<a href="/">首页</a> &gt; <a href="/Member/MemberCenter/">会员中心</a>
				&gt; <a href="/Member/MemberCenter/">会员中心</a>
			</div>
			<div class="wrapper about clearfix">
				<div class="pull-left right-main">
					<!--中间部分  -->
					<div class="right-main-title">我的收藏</div>
					<div class="collection">
						<c:forEach items="${sessionScope.coll}" var="c">
						<div class="collection-item">
							<a href="commodityDetails.shtml?id=${c.comdetailsid}" class="img-block">
							<img src="image/commodity/${c.commodityDetails.comimage}">
							</a> <a href="/product/9012473.html" class="collection-title">${c.commodityDetails.content}</a>
							<a href="/product/9012473.html" class="collection-money">${c.commodityDetails.outprice}
								</a>
							<div class="collection-btns">
								<a class="collection-btn" data-id="${c.comdetailsid}">加入购物车</a>
								<div class="collection-btn2 collection-check-delete qu-shou" data-id="${c.comdetailsid}">取消收藏</div>
							</div>
						</div>

					</c:forEach>
					</div>
					<!--中间到这 -->
				</div>
				<!--隐藏div  -->
				<div class="modal fade cancel-collection in" id="shou" style="display: none;">
					<div class="modal-dialog" style="width: 312px;height:228px;margin-top: 290px;">
						<div class="modal-content" style="padding-bottom: 36px;">
							<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span id="colse">×</span></button>
							<img src="https://img02.hua.com/pc/Images/2021new/address-delete-icon.png" alt="" class="delete-address-icon">
							<div class="delete-address-title">确定取消该订单吗?</div>
							<div class="consigneeModal-btns">
								<div class="c-btn consigneeModal-btn consigneeModal-btn-grey"id="close" style="width:108px;margin: 0 24px 0 36px;">取消</div>
								<div class="c-btn consigneeModal-btn" id="cancel-collection-submit" style="width:108px;">确定</div>
							</div>
						</div>
					</div>
				</div>
				<!--隐藏div到这  -->

				<!-- 导流-->
				<div class="customer">
					<div class="customer-service customer-service-open">
						<div class="customer-service-title">我是您的专属助理</div>
						<img class="customer-service-img"
							src="https://img02.hua.com/wxmp/hua/wx-code.png">
						<div class="customer-service-sub">扫描二维码加我微信</div>
						<div class="customer-service-hi">Hi~</div>
						<div class="customer-service-close">
							<div class="line"></div>
							<div class="line"></div>
						</div>
					</div>
				</div>
				<%@include file="GeLeft.jsp"%>
			</div>
		</div>
	</div>
	<!-- 尾部导航 -->
	<%@ include file="bottom.jsp"%>

	<script type="text/javascript" src="//img02.hua.com/pc/js/common.js"></script>
	<script type="text/javascript" src="js/flower.js"></script>
	<script type="text/javascript" src="js/jquery-3.6.0.js"></script>
	<script type="text/javascript" src="layui/layui.js"></script>
	<script type="text/javascript">
		$(function (){
			/*点击取消收藏*/
			$(".qu-shou").click(function (){
				$("#shou").show();
				/*获取商品id*/
				let id=$(this).attr("data-id");
				/*点击确认删除收藏*/
				$("#cancel-collection-submit").click(function (){
					$.ajax({
						url:"DeleteCollectServlet.shtml",
						type:"get",
						data:{"id":id},
						success:function (relust){
							$("#shou").hide();
							if (relust){
								alert("取消成功");
								location.href="collectServlet";
							}else{
								alert("取消失败");
							}
						}
					});
				});
			});
			$("#colse").click(function (){
				$("#shou").hide();
			});
			$("#close").click(function (){
				$("#shou").hide();
			});

				//加入购物车操作
			$(".collection-btn").click(function(){
					//获取商品编号
					let id =$(this).attr("data-id");
					//alert("点击加入购物车成功");
					//去找servlet验证是否登录
					$.post("toShoping.shtml",{"doWhat":"checkLogin"},function(data){
						if(data=="false"){
							alert("请先进行登录哦！");
						}else{
							//发送请求将改商品添加到购物车
							$.post("toShoping.shtml",{"id":id,"doWhat":"addShoping"},function(result){
								// 将新的购物车数量 更新一下
								//上方购物车数量
								$("#gwcCount").html("("+result+")");
								//右侧购物车数量
								$(".buy-count").html(result);
								$(".tishi").show().html("添加购物车成功");
								setTimeout(function(){
									//两秒后提示框隐藏
									alert("加入成功!");
								},10);
							});
						}
					});
				});
			});

	</script>

</body>
